package com.lzc.controller;

import com.lzc.pojo.vo.ArticlePublishVo;
import com.lzc.pojo.vo.Result;
import com.lzc.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文章功能控制器接口
 */
@RestController
@RequestMapping("/im/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    /**
     * 发布文章
     * @param articlePublishVo 文章信息VO
     * @return
     */
    @PostMapping("/publish")
    public Result publishArticle(@RequestBody ArticlePublishVo articlePublishVo){
        return articleService.publishArticle(articlePublishVo);
    }

    /**
     * 展示文章列表
     */
    @GetMapping("/list")
    public Result findArticleNewList(){
        return articleService.findArticleNewList();
    }

    /**
     * 获取当前用户发布的文章集合
     * @return list
     */
    @GetMapping("/current/user")
    public Result findCurrentUserArticle(){
        return articleService.findCurrentUserArticle();
    }

    /**
     * 逻辑删除，回收站还可以查看到
     */
    @PostMapping("/to/recycle/{id}")
    public Result deleteArticleToRecycle(@PathVariable("id") Long id){
        return articleService.deleteArticleToRecycle(id);
    }

    /**
     * 查看回收站
     * @return
     */
    @GetMapping("/current/user/recycle")
    public Result showRecycle(){
        return articleService.showRecycle();
    }

    /**
     * 真正删除
     */
    @PostMapping("/delete/article/{id}")
    public Result deleteArticle(@PathVariable("id") Long id){
        return articleService.deleteArticle(id);
    }
}
